package com.jar.exercise.集合和数据结构.arrayList去除重复元素;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/**
 * @author ZhangShengHao
 * @className Demo
 * @description TODO
 * @date 2020/2/25 11:26
 */
public class Demo {

	public static void main(String[] args) {

		List<Student> list = new ArrayList<>();
		list.add(new Student(1, "张三"));
		list.add(new Student(3, "李四"));
		list.add(new Student(2, "王五"));
		list.add(new Student(1, "张三"));
		System.out.println("原数据-----------");
		for (Student student : list) {
			System.out.println(student);
		}
		System.out.println("去重复后-----------");
		HashSet<Student> set = new HashSet<>(list);
		for (Student student : set) {
			System.out.println(student);
		}
	}
}
